{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a2408d6e-8e07-47e5-a7e3-daf3022a44de",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Setup OpenAI Agent\n",
    "import openai\n",
    "\n",
    "openai.api_key = \"sk-your-key\"\n",
    "from llama_index.agent import OpenAIAgent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3e91e13e-d7da-47d1-8122-5e11bb1b5a5a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: bing_news_search with args: {\n",
      "  \"query\": \"latest news about superconductors\"\n",
      "}\n",
      "Got output: [['Scientists skeptical of superconductor claims that went viral', 'A recent claim by South Korean researchers that they have created a material which works as a superconductor at room temperature—long a holy grail of physics—has been met with huge excitement on social media but skepticism from scientists.', 'https://phys.org/news/2023-08-scientists-skeptical-superconductor-viral.html'], [\"Room-temperature superconductors: The facts behind the 'holy grail' of physics\", 'Onto this crowded scene comes LK-99, a material whose resistivity, its researchers claim, drops to near zero at 86 F (30C). The material is made up of mixed powders containing lead, oxygen, sulfur and phosphorus which is doped with copper. It is also relatively easy to manufacture and test.', 'https://www.msn.com/en-us/news/technology/room-temperature-superconductors-the-facts-behind-the-holy-grail-of-physics/ar-AA1eVoxP'], ['Scientists Sceptical Of Superconductor Claims That Went Viral', 'A recent claim by South Korean researchers that they have created a material which works as a superconductor at room temperature -- long a holy grail of physics -- has been met with huge excitement on social media but scepticism from scientists.', 'https://www.barrons.com/news/scientists-sceptical-of-superconductor-claims-that-went-viral-ee5e0918?refsec=topics_afp-news']]\n",
      "========================\n",
      "Here are some of the latest news articles about superconductors:\n",
      "\n",
      "1. \"Scientists skeptical of superconductor claims that went viral\" - This article discusses a recent claim by South Korean researchers that they have created a material which works as a superconductor at room temperature. The claim has generated excitement on social media but skepticism from scientists. [Read more](https://phys.org/news/2023-08-scientists-skeptical-superconductor-viral.html)\n",
      "\n",
      "2. \"Room-temperature superconductors: The facts behind the 'holy grail' of physics\" - This article provides information about LK-99, a material that claims to exhibit superconductivity at room temperature. The material is made up of mixed powders containing lead, oxygen, sulfur, and phosphorus, and it is relatively easy to manufacture and test. [Read more](https://www.msn.com/en-us/news/technology/room-temperature-superconductors-the-facts-behind-the-holy-grail-of-physics/ar-AA1eVoxP)\n",
      "\n",
      "3. \"Scientists Sceptical Of Superconductor Claims That Went Viral\" - This article also discusses the claim made by South Korean researchers about a room temperature superconductor. It highlights the excitement on social media but the skepticism from scientists. [Read more](https://www.barrons.com/news/scientists-sceptical-of-superconductor-claims-that-went-viral-ee5e0918?refsec=topics_afp-news)\n",
      "\n",
      "You can click on the links to read the full articles.\n"
     ]
    }
   ],
   "source": [
    "from llama_hub.tools.bing_search.base import BingSearchToolSpec\n",
    "\n",
    "bing_tool = BingSearchToolSpec(api_key=\"your-key\")\n",
    "agent = OpenAIAgent.from_tools(\n",
    "    bing_tool.to_tool_list(),\n",
    "    verbose=True,\n",
    ")\n",
    "\n",
    "print(agent.chat(\"whats the latest news about superconductors\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "80a8981a-ba62-4c86-a755-a4ec26051805",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: bing_image_search with args: {\n",
      "  \"query\": \"LK-99 superconductor\"\n",
      "}\n",
      "Got output: [['What is the LK-99 superconductor and why is it called the Holy Grail of ...', 'https://cdn.computerhoy.com/sites/navi.axelspringer.es/public/media/image/2023/08/superconductor-lk-99-3103376.jpg?tf=1200x'], ['The LK-99 controversy: between Nobel prospects and skeptical scrutiny ...', 'https://media.cybernews.com/images/featured-big/2023/08/LK-99-superconductor.png'], ['Will the LK-99 superconductor change the world?', 'https://images.moneycontrol.com/static-mcnews/2023/08/lk-99-superconductor-bbo-770x433.jpg?impolicy=website&width=770&height=431']]\n",
      "========================\n",
      "Here are some images of the LK-99 superconductor:\n",
      "\n",
      "1. ![LK-99 superconductor](https://cdn.computerhoy.com/sites/navi.axelspringer.es/public/media/image/2023/08/superconductor-lk-99-3103376.jpg?tf=1200x)\n",
      "\n",
      "2. ![LK-99 superconductor](https://media.cybernews.com/images/featured-big/2023/08/LK-99-superconductor.png)\n",
      "\n",
      "3. ![LK-99 superconductor](https://images.moneycontrol.com/static-mcnews/2023/08/lk-99-superconductor-bbo-770x433.jpg?impolicy=website&width=770&height=431)\n",
      "\n",
      "Please note that these images are for illustrative purposes and may not represent the exact appearance of the LK-99 superconductor.\n"
     ]
    }
   ],
   "source": [
    "print(agent.chat(\"what does lk-99 look like\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4aa378d0-b797-4323-a91c-06baf19fe4b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: bing_video_search with args: {\n",
      "  \"query\": \"LK-99 superconductor levitation\"\n",
      "}\n",
      "Got output: [['LK-99, a candidate for room temperature superconductivity', 'https://www.youtube.com/watch?v=AFDH4asSdqk'], ['「超電導体の磁気浮上を室温かつ常圧で確認した」とされるムービー【LK-99】', 'https://www.youtube.com/watch?v=aw5sw5TDihU'], ['Boaz Almog \"levitates\" a superconductor', 'https://www.youtube.com/watch?v=PXHczjOg06w']]\n",
      "========================\n",
      "Here are some videos of the LK-99 superconductor levitating:\n",
      "\n",
      "1. [LK-99, a candidate for room temperature superconductivity](https://www.youtube.com/watch?v=AFDH4asSdqk)\n",
      "\n",
      "2. [「超電導体の磁気浮上を室温かつ常圧で確認した」とされるムービー【LK-99】](https://www.youtube.com/watch?v=aw5sw5TDihU)\n",
      "\n",
      "3. [Boaz Almog \"levitates\" a superconductor](https://www.youtube.com/watch?v=PXHczjOg06w)\n",
      "\n",
      "You can click on the links to watch the videos.\n"
     ]
    }
   ],
   "source": [
    "print(agent.chat(\"is there any videos of it levitating\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56ca5c22-0eab-42ec-b038-7acb9cab710c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
